<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN" xml:lang="zh_CN" >
	<head>
  		<title>ZKAccess6.0 门禁管理系统</title>
  		<!-- 不从缓存中加载，每次必须加载国际化 -->
		<meta http-equiv="Pragma" content="no-cache" ></meta>
		<meta http-equiv="Cache-Control" content="no-cache"></meta>
		<meta http-equiv="Expires" content="0"></meta>
		
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"></meta>
		<meta http-equiv="description" content="this is my page"></meta>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta>
		<!-- 30分钟自动跳转到登录页面 
		<meta http-equiv="refresh" content="1800;url=http://www.baidu.com"></meta>
		 -->
		<!--解决IE8链接下划线贴得太近-->
		<meta name="robots" content="NONE,NOARCHIVE" />
		
<!-- 加载公共部分js和css begin-->

<link rel="stylesheet" type="text/css" href="/public/css/base.css" />
<link rel="stylesheet" type="text/css" href="/public/css/whole.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/public/css/head.css" />
<link rel="stylesheet" type="text/css" href="/public/css/dhtmlxGrid.css" />

<script src="/public/controls/jquery/jquery.js"></script>
<script src="/public/controls/jquery/jquery.form.js"></script>
<script src="/public/controls/jquery/jquery.validate.js"></script>
<script src="/public/controls/jquery/jquery.jplayer.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/public/controls/jquery/jquery.alerts.css"/>
<script type="text/javascript" src="/public/controls/jquery/jquery.alerts.js"></script>
<script type="text/javascript" src="/public/controls/jquery/jquery.hotkeys.js"></script>

<link type="text/css" rel="stylesheet" href="/public/controls/jBox/Skins/Default/jbox.css"/>
<script type="text/javascript" src="/public/controls/jBox/jquery.jBox-2.3.min.js"></script>
<script type="text/javascript" src="/public/controls/jBox/i18n/jquery.jBox-zh-CN.js"></script>
<script src="public_common.js.action"></script>
<!-- 加载公共部分js和css end-->
		
		
		<!-- 加载dhx组件的css和js begin-->
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxTree/codebase/dhtmlxtree.css" rel="stylesheet"/>
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxTabbar/codebase/dhtmlxtabbar.css" rel="stylesheet"/>
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxWindows/codebase/dhtmlxwindows.css" rel="stylesheet"/>
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxLayout/codebase/dhtmlxlayout.css" rel="stylesheet"/>
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxWindows/codebase/skins/dhtmlxwindows_dhx_skyblue.css" rel="stylesheet"/>
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_skyblue.css" rel="stylesheet"/>
		
		<!-- 工具栏（操作栏）控件 因为其dhtmlxcommon.js存在bug，所有使用了官网示例源码，为了保证后面的兼容，所以放到了最前面 -->
		<link charset="utf-8" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxToolbar/codebase/skins/dhtmlxtoolbar_dhx_skyblue.css" rel="stylesheet"/>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxToolbar/codebase/dhtmlxcommon.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxToolbar/codebase/dhtmlxtoolbar.js"></script>
		<!-- 
		<script charset="utf-8" type="text/javascript" src="http://www.dhtmlx.com/docs/products/dhtmlxToolbar/codebase/dhtmlxcommon.js"></script>
		<script charset="utf-8" type="text/javascript" src="http://www.dhtmlx.com/docs/products/dhtmlxToolbar/codebase/dhtmlxtoolbar.js"></script>
		 -->
		
		<!-- 下拉框控件 -->
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxCombo/codebase/dhtmlxcombo.css"/>
		<script  src="/public/controls/dhtmlx/dhtmlxCombo/codebase/dhtmlxcombo.js"></script>
		<script  src="/public/controls/dhtmlx/dhtmlxCombo/codebase/ext/dhtmlxcombo_whp.js"></script>
		<script  src="/public/controls/dhtmlx/dhtmlxCombo/codebase/ext/dhtmlxcombo_extra.js"></script>
		
		<!-- 因为所有控件中的dhtmlxcommon_debug.js 都是一样的，这里已grid为中心-->
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/dhtmlxcommon_debug.js"></script>
		
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxTree/codebase/dhtmlxtree.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_xw.js"></script>
		
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxTabbar/codebase/dhtmlxtabbar.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_attrs.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxLayout/codebase/dhtmlxlayout.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxLayout/codebase/dhtmlxcontainer.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxWindows/codebase/dhtmlxwindows.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxWindows/codebase/dhtmlxcontainer.js"></script>
		 
		<link rel="stylesheet" type="text/css" href="/public/controls/dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.css"/>
		<link rel="stylesheet" type="text/css" href="/public/controls/dhtmlx/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css"/>
		<link rel="stylesheet" type="text/css" href="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_pgn_bricks.css"/>
		
		
		<!-- 日期控件 -->
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxCalendar/codebase/dhtmlxcalendar.css"/>
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxCalendar/codebase/skins/dhtmlxcalendar_dhx_skyblue.css"/>
		<script type="text/javascript" src="/public/controls/dhtmlx/dhtmlxCalendar/codebase/dhtmlxcalendar.js"></script>
		
		<!-- 表单控件 -->
		<link rel="stylesheet" type="text/css" href="/public/controls/dhtmlx/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css"/>
		<script src="/public/controls/dhtmlx/dhtmlxForm/codebase/dhtmlxform.js"></script>
		
	
		<script type="text/javascript">
			window.dhx_globalImgPath = "/public/controls/dhtmlx/dhtmlxCombo/codebase/imgs/";
		</script>
		
		<!-- 基本核心js -->
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
		
		<!-- 加载html中table时 -->
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_start.js"></script>
		
		<!-- 处理json格式的js(如分页) -->
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_data.js"></script>
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_json.js"></script>
		<!-- 分页过滤和分隔符 -->
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_pgn.js"></script>
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js"></script>
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_markers.js"></script>
		<!-- 分栏可横向滚动 -->
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_splt.js"></script>
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/excells/dhtmlxgrid_excell_cntr.js"></script>
		<!-- 自定义显示字段-->
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_hmenu.js"></script>
		<!-- 可拖动列 -->
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_mcol.js"></script>
		
		<!-- 保存信息到Cookie(列宽，自定义的显示字段等) -->
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_ssc.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_post.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_srnd.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/excells/dhtmlxgrid_excell_sub_row.js"></script>	
		<script src="/public/controls/dhtmlx/dhtmlxGrid/codebase/ext/dhtmlxgrid_start.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxGrid/codebase/excells/dhtmlxgrid_excell_link.js"></script>
		<!-- 加载dhx组件的css和js end-->
		
		<!-- dhx组件中的json树形菜单、左右选择js和cs -->
		<link charset="utf-8" title="no title" media="screen" type="text/css" href="/public/controls/dhtmlx/dhtmlxForm/codebase/skins/dhtmlxform_dhx_skyblue.css" rel="stylesheet"/>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxForm/codebase/dhtmlxform.js"></script>
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_json.js"></script>
		<!-- 引入的js文件找不到，估计名字写错，如果改的不对，请撤回  update by: ob.huang  2013-05-15 -->
		<script charset="utf-8" type="text/javascript" src="/public/controls/dhtmlx/dhtmlxTree/codebase/ext/dhtmlxtree_lf.js"></script>

		<!-- 图表控件 -->
		<script src="/public/controls/dhtmlx/dhtmlxChart/codebase/dhtmlxchart.js" type="text/javascript"></script>
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxChart/codebase/dhtmlxchart.css"/>
		
		<!-- Menu控件 -->
		<script src="/public/controls/dhtmlx/dhtmlxMenu/codebase/dhtmlxmenu.js" type="text/javascript"></script>
		<script src="/public/controls/dhtmlx/dhtmlxMenu/codebase/ext/dhtmlxmenu_ext.js" type="text/javascript"></script>
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxMenu/codebase/skins/dhtmlxmenu_dhx_skyblue.css"/>
		
		<!-- dataView控件 -->
		<script type="text/javascript" src="/public/controls/dhtmlx/dhtmlxDataView/codebase/dhtmlxdataview.js"></script>
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxDataView/codebase/dhtmlxdataview.css"/>
		
		
		
		<!-- 封装调用dhtmlxGrid的js 不适用datalist的不需要加载该脚本（上同），需处理--------- -->	
		
		<script src="public_dhtmlxComboxTree.js.action"></script>
		<script src="public_dhtmlxPaging.js.action"></script>
		<script src="public_dhtmlxCommon.js.action"></script>
		<script src="public_commonValidate.js.action"></script>
		<script src="public_search.js.action"></script>
		<script src="public_init.js.action"></script>
		<!-- 消息提示框控件 -->
		<link rel="STYLESHEET" type="text/css" href="/public/controls/dhtmlx/dhtmlxMessage/codebase/skins/dhtmlxmessage_dhx_skyblue.css"/>
		<script type="text/javascript" src="/public/controls/dhtmlx/dhtmlxMessage/codebase/dhtmlxmessage.js"></script>
				
		<script type="text/javascript">
			dhtmlx.skin = "dhx_skyblue";
			//系统信息配置类
			var sysCfg = 
			{
				dhxSkin : "dhx_skyblue",
				rootPath : "",
				devMode : Boolean("false"),
				dhxShortDateFmt : "%Y-%m-%d",
				dhxLongDateFmt : "%Y-%m-%d %H:%i:%s",
				sysShortDateFmt : "yyyy-MM-dd",
				sysLongDateFmt : "yyyy-MM-dd H:mm:ss",
				ret : "ret",
				msg : "msg",
				data : "data",
				success : "ok",
				error : "400",
				warning : "500"
			};
			//消息控件的使用类型的类
			var msgType = 
			{
				info : "info",
				success : "success",
				warning : "warning",
				error : "error",
				loading : "loading"
			};
		</script>
		<style type="text/css">
			.title{
				background-color: #a4bed4;
				height: 20px;
				line-height: 20px;
				color: #FFF;
				border-bottom: 2px solid #8ba1b3;
				font-weight: bold;
				text-align:left;
			}
				html,body {
					MIN-WIDTH: 400px !important;
					MIN-height: 200px !important;
				}
		</style>
  	</head>
	<body style="overflow: visible;">
		
	<input type="hidden" id="systemCode" value="acc" />
	<div style="width:100%;height:100%;overflow: hidden;">
	    <div id="devMonitorGridSearch" class="searchTopBox" style="padding-top: 1px; padding-bottom: 1px;">
		    <table cellspacing="0" cellpadding="0" class="searchTable">
	  			<tr valign="middle">
	  				<td>
	  					区域
	  				</td>
					<td>
						<div id="areaZoneId" objName="baseArea" selectWidth="120"></div>
					</td>
					<td>
						状态
					</td>
					<td>
						<select style="width: 80px;" id="devStatus" onchange="devInfoFilter()">
							<option value="">------</option>
							<option value="normal">正常</option>
							<option value="exception">异常</option>
							<option value="disable">禁用</option>
						</select>
					</td>
					<td>
						设备名称
					</td>
					<td>
						<input id="devName" type="text" style="width: 120px;" onchange="devInfoFilter()" onkeyup="devInfoFilter()"/>
					</td>
					<td>
						序列号
					</td>
					<td>
						<input id="devSn" type="text" style="width: 120px;" onchange="devInfoFilter()" onkeyup="devInfoFilter()"/>
					</td>
					<td>
						<a id="clearSearch" href="javascript:clearCondition('devMonitorGridSearch');areaTree.setSubChecked(0,false);devInfoFilter();">清空</a>
					</td>
	   			</tr>
		    </table>
	    </div>
    	<div id="devMonitorGridbox" style="width:100%;height:100%;background-color:white;overflow:hidden;border-top: none;border-left: none;"></div>
    </div>
    <div id="devMonitorGridbox_footer" style="display: none">
    	<div style="float: left;">
    		当前设备台数：<span id="devCount">0</span>
    	</div>
		<div class="divBorder" style="margin-left: 5%;">
    		<img height="12px" src="/public/images/greenPilot.png"/>正常：<span id="normalCount">0</span>&nbsp; 
			<img height="12px" src="/public/images/redPilot.png"/>异常：<span id="exceptionCount">0</span>&nbsp;
			<img height="12px" src="/public/images/yellowPilot.png"/>禁用：<span id="disbleCount">0</span>
	    </div>
	    <div class="divBorder" style="margin-left: 5%;">
	    	待执行命令总数：<span id="cmdCount">0</span>
	    </div>
	    <div class="divBorder displayN" style="margin-left: 5%;">
	    	消息提示
	    	<input id="msgCheckbox" type="checkbox" onclick="enableMsg(this)"/></div>
		<!-- <div style="float: right;">
			<img id="monitorStateImg" src="/public/images/greenPilotLamp.gif" height="12px"/>
			暂停监控
			<input type="checkbox" id="disableMonitorId" onclick="disableMonitor(this)"/>
		</div> -->
    </div>
		
		<!-- 
		<#include "/public/template/bottom.html">
		 -->
		
			<!-- 执行自定义的脚本 -->
<script type="text/javascript">
	var gridName = "devMonitorGridbox";
	//进行条件过滤
	function devInfoFilter()
	{
		//alert(areaTree.comboxObj.getActualValue());
		//console.log(areaTree.comboxObj.getActualValue() + "---" + areaTree.getAllChecked());
		if(areaTree.comboxObj.getActualValue() == areaTree.getAllChecked())
		{
			/*
			mygrids[gridName].forEachRow(function(id){
				console.log(id);
				var value = mygrids[gridName].cells(id,2).getValue();
				var areaInfo = areaTree.comboxObj.getComboText();
				var areaIdArray = areaTree.comboxObj.getActualValue().split(",");
				var areaId = mygrids[gridName].getUserData(id, "areaId") + "";
				
				var areaFlag = (areaInfo == "" ? true : (areaIdArray == "" ? value.indexOf(areaInfo) != -1 : $.inArray(areaId, areaIdArray) != -1))
				
				if(areaFlag
					&& ($("#devStatus").val() == "" || $("#devStatus").val() == mygrids[gridName].getUserData(id,"status"))
					&& ($("#devName").val() == "" || mygrids[gridName].cells(id,0).getValue().indexOf($("#devName").val()) != -1)
					&& ($("#devSn").val() == "" || mygrids[gridName].cells(id,1).getValue().indexOf($("#devSn").val()) != -1))
				{
					mygrids[gridName].setRowHidden(id,false);
					//return true;
				}
				else
				{
					mygrids[gridName].setRowHidden(id,true);
					//return false;
				}
				
		   	});*/
			
			mygrids[gridName].filterBy(2,function(value, id){
				//alert(22);
				var areaInfo = areaTree.comboxObj.getComboText();
				var areaIdArray = areaTree.comboxObj.getActualValue().split(",");
				var areaId = mygrids[gridName].getUserData(id, "areaId") + "";
				
				var areaFlag = (areaInfo == "" ? true : (areaIdArray == "" ? value.indexOf(areaInfo) != -1 : $.inArray(areaId, areaIdArray) != -1))
				
				if(areaFlag
					&& ($("#devStatus").val() == "" || $("#devStatus").val() == mygrids[gridName].getUserData(id,"status"))
					&& ($("#devName").val() == "" || mygrids[gridName].cells(id,0).getValue().toUpperCase().indexOf($("#devName").val().toUpperCase()) != -1)
					&& ($("#devSn").val() == "" || mygrids[gridName].cells(id,1).getValue().indexOf($("#devSn").val()) != -1))
				{
					return true;
				}
				else
				{
					return false;
				}
			});
			
			calculateFooterValues();
		}
	}
	var areaTree = loadComboxTree("areaZoneId","baseAreaAction!getAreaTreeJson.action", devInfoFilter);
	
	
	//绑定全局下拉树的keyup事件
	/*
	areaTree.comboxObj.DOMelem.onkeyup = function(e){
		//绑定回车确定事件代码
		var theEvent = window.event || e;
		var key = theEvent.keyCode || theEvent.which||e.charCode;
		
		var comboText = areaTree.comboxObj.getComboText();
		if(key != 13 )//不为回车键时，将清除所有节点
		{
			areaTree.setSubChecked(0,false);
		}
		areaTree.comboxObj.setComboValue(areaTree.getAllChecked());
		areaTree.comboxObj.setComboText(comboText);
		devInfoFilter();
	};*/
	
	//var devCombo = new dhtmlXCombo("devZone", "devZone", 120);
	
	var devMonitorTimeout;
	var init = true;
    //用于向服务器端获取实时数据
    //var scrollTop = 0;//grid的滚动条定位的坐标
    var clientId = new Date().getTime();//一个用户可以开多个页面，该值用来保存当前页面创建时间，及初始化状态的时间。
	$("#" + gridName).height($("#" + gridName).outerHeight() - $("#" + gridName).position().top);
    function refreshDevMonitorInfo()
    {
    	//scrollTop = $(".objbox")[0].scrollTop;//这是grid控件的自动生成的加载数据div的class名称
    	var url = "/accDevMonitorAction!getDevMonitorInfo.action?clientId="+clientId;
        if($("#disableMonitorId").attr("checked") != "checked")
        {
	    	$.ajax({
	            type: "GET",
	            url: url,
	            dataType: "json",
	            async: true,
	            success: function(dataObj)
	            {
	       			if(init)//初始化
                    {
	                   	mygrids[gridName].clearAll();//清除原来的数据
	                   	mygrids[gridName].enableSmartRendering(dataObj.rows.length > 1000 ? true : false);
	                   	mygrids[gridName].parse(dataObj,function(){
	                   		calculateFooterValues();
	                   		timeoutFunction();//由于parse为异步加载，所有必需在回调里进行timeout调用，进行分离
	                   	},"json");
                   		showLoading(false, gridName);
                    }
	       			else if(dataObj.rows.length > 0)
	       			{
	       				var addNum = 0;
	       				var addDevMsg = "";
	       				for(var index in dataObj.rows)
		                {
	       					var id = dataObj.rows[index].id;
	       					if(mygrids[gridName].doesRowExist(id))//判断是否存在该id（修改）
	   						{
		                    	for(var i = 0; i < mygrids[gridName].getColumnsNum(); i++)
		                    	{
		                    		mygrids[gridName].cells(id, i).setValue(dataObj.rows[index].data[i]);
		                    	}
		                    	mygrids[gridName].setRowTextStyle(id, dataObj.rows[index].style);
		                    	mygrids[gridName].setUserData(id,"status",dataObj.rows[index].userdata["status"]);
		                    	calculateFooterValues();
		                    }
		                    else//新增
		                    {
		                    	mygrids[gridName].addRow(id, dataObj.rows[index].data);
		                    	mygrids[gridName].setRowTextStyle(id, dataObj.rows[index].style);
		                   		mygrids[gridName].setUserData(id,"status",dataObj.rows[index].userdata["status"]);
		                   		mygrids[gridName].setUserData(id,"areaId",dataObj.rows[index].userdata["areaId"]);
		                    	addDevMsg += dataObj.rows[index].data[0] + "  " + dataObj.rows[index].data[1] + "<br/>";
		                    	addNum ++;
		                    }
		                }
	       				if(addNum != 0)//当有设备新增时将重新过滤
	       				{
	       					devInfoFilter();
	       					devConnectMsg(addDevMsg);
	       				}
	       				timeoutFunction();
	       			}
	       			else
	       			{
	       				timeoutFunction();
	       			}
	
				},
	            error:function (XMLHttpRequest, textStatus, errorThrown)
	     		{
					window.clearTimeout(devMonitorTimeout);
		       	}
	        });
    	}
    }

	mygrids[gridName] = new dhtmlXGridObject(gridName);
	mygrids[gridName].setImagePath(sysCfg.rootPath + "/public/controls/dhtmlx/dhtmlxGrid/codebase/imgs/");

	//mygrids[gridName].setHeader("设备名称, 序列号, 操作状态, 当前状态, 待执行命令条数, 相关操作");//需要从服务器端动态获取，根据不同语言显示不同的header，不再写死。-darcy20130106
	mygrids[gridName].setHeader("设备名称, 序列号, 区域, 操作状态, 当前状态, 待执行命令条数, 相关操作");//需要从服务器端动态获取，根据不同语言显示不同的header，不再写死。-darcy20130106
	mygrids[gridName].setColumnMinWidth("70,70,70,70,70,70,150");
	mygrids[gridName].setInitWidths("120,120,150,150,100,150,*");//150
	mygrids[gridName].setColAlign("left,left,left,left,left,left,left");
	mygrids[gridName].setColTypes("ro,ro,ro,ro,ro,ro,ro");//ro
	mygrids[gridName].setColSorting("str,str,str,str,str,int,na");
	//加载数据时进行提示
	mygrids[gridName].init();
	showLoading(true, gridName);
	mygrids[gridName].enableHeaderMenu("false,true,true,true,true,true,false");
	mygrids[gridName].enableResetHeight = true;
	mygrids[gridName].setSkin(sysCfg.dhxSkin);
	//加载设备总体信息模块
	
	mygrids[gridName].attachFooter($("#" + gridName + "_footer").html() + "," +
									"#cspan," +
									"#cspan," +
									"#cspan," +
									"#cspan," +
									"#cspan," +
									"#cspan",
									"text-align:left;font-style:normal;");
	$("#" + gridName + "_footer").remove();
	//从cookie中获取消息提示
	document.getElementById("msgCheckbox").checked = eval(getCookie("accEnableMsg1"));
	
	mygrids[gridName].setSizes(false);
	
	//设置grid底部的一些对象的值
	function calculateFooterValues()
	{
		//过滤完后进行条数统计
		if(mygrids[gridName].getRowsNum() == 0 && !document.getElementById(gridName + "noPrompt"))
   		{
			$("#" + gridName + " .objbox").append("<p id='" + gridName + "noPrompt' style='color:red;'>系统中找不到设备信息！</p>");//不存在设备
   		}
   		else if(mygrids[gridName].getRowsNum() > 0)
   		{
   			$("#"+ gridName + "noPrompt").remove();//清除找不到设备的提示
   		}
		
		var normalCount = 0;//正常数量
	    var exceptionCount = 0;//异常数量
	    var disbleCount = 0;//禁用数量
	    var devSumCount = 0;//待执行命令总数
		var ids= mygrids[gridName].getAllRowIds(",") != "" ?  mygrids[gridName].getAllRowIds(",").split(",") : {};
        for(var i = 0; i < ids.length; i++)
        {
            switch (mygrids[gridName].getUserData(ids[i],"status"))
	    	{
				case "normal":
					normalCount++;
					break;
				case "exception":
					exceptionCount++;
					break;
				case "disable":
					disbleCount++;
					break;
			}
            devSumCount += parseFloat(mygrids[gridName].cells2(i, 5).getValue());
        }
        
		devSumCount = isNaN(devSumCount) ? 0 : devSumCount;
	    
		$("#cmdCount").html(devSumCount);
		
		$("#normalCount").html(normalCount);
		
		$("#exceptionCount").html(exceptionCount);
		
		$("#disbleCount").html(disbleCount);
		$("#devCount").html(mygrids[gridName].getRowsNum());
			
	    return true;
	}

	//定时循环
	function timeoutFunction()
	{
		/*
		if($(".objbox").size()>0)
		{
			 $(".objbox")[0].scrollTop = scrollTop;//保持滚动条的位置
		}*/
		mygrids[gridName].setSizes(false);
		//devMonitorTimeout = window.setTimeout('refreshDevMonitorInfo()', 2000)//等2秒执行刷新函数
		devMonitorTimeout = setTimeout("refreshDevMonitorInfo()", 2000);
		init = false;
	}
	
	//暂停监控
	function disableMonitor(obj)
	{
		if(obj.checked)//选中时则暂停
		{
			//window.clearTimeout(devMonitorTimeout);
			clearTimeout(devMonitorTimeout);
			//监控已暂停:监控已暂停
			openMessage(msgType.warning, "监控已暂停");
			$("#monitorStateImg").attr("src", sysCfg.rootPath +"/public/images/redPilotLamp.gif");
		}
		else
		{
			//监控已开启:监控已开启
			openMessage(msgType.success, "监控已开启");
			$("#monitorStateImg").attr("src", sysCfg.rootPath +"/public/images/greenPilotLamp.gif");
			refreshDevMonitorInfo();
		}
	}
	
	//暂停监控
	function enableMsg(obj)
	{
		if(obj.checked)//选中时则暂停
		{
			//监控已暂停:监控已暂停
			openMessage(msgType.success, "已开启消息提示");
		}
		else
		{
			//监控已开启:监控已开启
			openMessage(msgType.warning, "已关闭消息提示");
		}
		
		createCookie("accEnableMsg1", obj.checked);
	}
	
	//设备连接消息提示
	function devConnectMsg(addDevMsg)
	{
		var msgObj = document.getElementById("msgCheckbox");
		if(msgObj.checked)//选中时开启
		{
			$.jBox.messager(addDevMsg, "新增设备", 0, {
			    icon: 'info',
			    top: '20',
			    showType: 'fade',
			    buttons: { '不再提示': true },
			    submit: function (v, h, f) {
			    	msgObj.checked = false;
			    	enableMsg(msgObj);
			        return false;
			    }
			});
		}
	}

	function clearCmdCache(devId)
	{
		 messageBox({messageType:"confirm",text:"确定要清除命令队列？",callback:function(result){
			 if(result)
			 {
				 var operateURL =  '/accDevMonitorAction!clearCmdCache.action?devId=' + devId;
	             $.ajax({
	                 type: "POST",
	                 url: operateURL,
	                 dataType: "json",
	                 async: false,
	                 success: function(result)
	                 {
	                    dealRetResult(result,null);
	                 },
	                 error: function (XMLHttpRequest, textStatus, errorThrown)
	                 {
	                 	if(XMLHttpRequest.status == 0)
						{
							openMessage(msgType.error, "服务器连接失败！");
						}
						else
						{
							openMessage(msgType.error, "服务器处理数据失败，请重试！错误码：" + XMLHttpRequest.status);
						}
	                 }
	             });
			}
		}});//确定要清除命令队列？
	}
	refreshDevMonitorInfo();//初始化监控进程
	//mygrids[gridName].makeSearch("devSn",1);
	//$("#devMonitorGridbox .xhdr .hdr tr:first").after("<tr><td id='devMonitorGridboxTd' colspan='6'><td></tr>");
	//$("#devMonitorGridboxTd").prepend($("#devMonitorGridSe"));
	
</script>
	</body>

</html>

<!-- end of mainContent -->

